package org.example.stream.demo;

import java.util.Arrays;
import java.util.List;
import java.util.Optional;

public class ReduceMain {
    public static void main(String[] args) {
        List<String> langs = Arrays.asList("Java", "Python", "JavaScript", "C++");
        Optional<String> longest = langs.stream()
                .reduce((s1, s2) -> s1.length() > s2.length() ? s1 : s2);

        System.out.println(longest.get());
    }
}
